package jhunter;

import jhunter.security.JHunterSecurityManger;
import jhunter.web.mvc.params.FlashManger;
import jhunter.web.mvc.params.SessionFlashManger;
import jhunter.web.mvc.view.DefaultViewResovle;
import jhunter.web.mvc.view.ViewResovle;

import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

@Configuration
public class JHunterConfConfig {

	@Bean
	public ViewResovle getViewResovle() {
		return new DefaultViewResovle();
	}

	@Bean
	public FlashManger getFlashManger() {
		return new SessionFlashManger();
	}

	@Bean
	public static PropertyPlaceholderConfigurer getPlaceholderConfigurer() {
		PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
		configurer.setLocation(new ClassPathResource("app.properties"));
		return configurer;
	}

	@Bean
	public JHunterSecurityManger getJHunterSecurityManger() {
		JHunterSecurityManger manger = new JHunterSecurityManger();
		return manger;
	}

	@Bean(destroyMethod = "destroy")
	public EhCacheManager getEhCacheManager() {
		EhCacheManager manager = new EhCacheManager();
		return manager;
	}

}
